<template>
  <div>
    <el-table :data="exprRecordList" style="width: 100%" :stripe="true" border>
      <el-table-column prop="expeName" label="实验名称" width="180">
      </el-table-column>
      <el-table-column prop="operUsername" label="操作人" width="180">
      </el-table-column>
      <el-table-column prop="operTime" label="操作时间"> </el-table-column>
      
    </el-table>
    <!-- 分页栏 -->
    <el-pagination
      layout="total, sizes, prev, pager, next, jumper"
      :page-size="pageSize"
      :page-sizes="[5, 10]"
      :total="total"
      :current-page="currentPage"
      @current-change="changeCurrent"
      @size-change="changeSize"
      align="center"
      style="margin-top: 10px"
    ></el-pagination>
  </div>
</template>

<script>
export default {
  // 此处的message是实验id
  props: ["message"],
  data() {
    return {
      exprRecordList: [],
      // 当前页码
      currentPage: 1,
      // 当前页面条数
      pageSize: 5,
      total: 0,
    };
  },
  methods: {
    // 发送请求，获取数据集
    getRecord(pageSize, pageNum, expeId) {
      // 通过id拿到数据集
      this.$http({
        url:
          "expe-record/list?pageSize=" +
          pageSize +
          "&pageNum=" +
          pageNum +
          "&expeId=" +
          expeId,
        method: "get",
      })
        .then((response) => {
          if (response.data.code == 0) {
            this.exprRecordList = response.data.data.data;
            this.total = response.data.data.total;
          }
        })
        .catch((err) => err);
    },
    // 改变当前的页码
    changeCurrent(currentPage) {
      this.currentPage = currentPage;
      console.log(currentPage);
      // 重新发送请求，获取数据集
      this.getRecord(this.pageSize, this.currentPage, this.message);
    },
    // 改变当前的显示条数
    changeSize(pageSize) {
      this.pageSize = pageSize;
      this.getRecord(this.pageSize, this.currentPage, this.message);
    },
  },
  watch: {
    message(newValue) {
      // 通过id拿到数据集
      this.getRecord(this.pageSize, this.currentPage, newValue);
    },
  },
};
</script>

<style>
</style>